﻿using eProcurement.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace eProcurement.members
{
    public partial class Site : System.Web.UI.MasterPage
    {
        protected void Page_Load( object sender, EventArgs e )
        {
            Manager manager = new Manager();
            if ( manager.IsPurchaser( Context.User.Identity.Name ) )
            {
                settingslink.Attributes.Add( "href", "Settings2.aspx" );
            }
            else
            {
                settingslink.Attributes.Add( "href", "Settings.aspx" );
                liMyProjects.InnerHtml = "<a href='MyBids.aspx'>My Bids</a>";
            }

            ClearClass();

            if ( Request.Url.AbsolutePath.Contains( "/OpenBids.aspx" ) )
            {
                liOpenBid.Attributes.Add( "class", "active" );
            }
            else if ( Request.Url.AbsolutePath.Contains( "/CompanyListing.aspx" ) || Request.Url.AbsolutePath.Contains( "/Company.aspx" ) )
            {
                liCompanyListing.Attributes.Add( "class", "active" );
            }
            else if ( Request.Url.AbsolutePath.Contains( "/Categories.aspx" ) )
            {
                liCategories.Attributes.Add( "class", "active" );
            }
            else if ( Request.Url.AbsolutePath.Contains( "/NewProject.aspx" ) )
            {
                liNewProject.Attributes.Add( "class", "active" );
            }
            else if ( Request.Url.AbsolutePath.Contains( "/MyProjects.aspx" ) || Request.Url.AbsolutePath.Contains( "/EditProject.aspx" ) )
            {
                liMyProjects.Attributes.Add( "class", "active" );
            }
        }

        private void ClearClass()
        {
            liMyProjects.Attributes.Remove( "class" );
            liOpenBid.Attributes.Remove( "class" );
            liCompanyListing.Attributes.Remove( "class" );
            liCategories.Attributes.Remove( "class" );
            liNewProject.Attributes.Remove( "class" );
        }
    }
}